﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Facebook;
using ThangNM_LIB.FUNC;

namespace FacebookApp
{
    public partial class About : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["AccessToken"] != null)
                {
                    FacebookClient FBClient = new FacebookClient();
                    FBClient.AppId =OtherEx.getAppSettings("AppId");
                    FBClient.AppSecret = OtherEx.getAppSettings("AppSecret");
                    FBClient.AccessToken = Convert.ToString(Session["AccessToken"]);
                    txtToken.Text = FBClient.AccessToken;
                    txtResult.Text = Convert.ToString(FBClient.Get("me?fields=id,first_name,last_name,link,middle_name,name,timezone,updated_time,verified,accounts"));
                }
                else
                {
                    txtToken.Text = "";
                    txtResult.Text = "Bạn chưa đăng nhập.";
                }


            }
            catch (Exception ex)
            {
                txtResult.Text = ex.ToString();
            }
            //var accessToken = Session["AccessToken"].ToString();
            //var client = new FacebookClient(accessToken);
            //dynamic result = client.Get("me", new { fields = "name,id" });
            //string name = result.name;
            //string id = result.id;

            //Response.Write(name + " - " + id);
        }
    }
}
